<template>
	<view>
		<view class="integral">
			<view class="xian" @tap="index = 0">
				<view :class="index==0?'btn-x':''">全部记录</view>
			</view>
			<view class="xian" @tap="index = 1">
				<view :class="index==1?'btn-x':''">积分收入</view>
			</view>
			<view class="xian" @tap="index = 2">
				<view :class="index==2?'btn-x':''">积分支出</view>
			</view>
		</view>
		<view class="count" v-if="integralList.length!=0">
			<view class="num" v-for="(item,i ) in integralList" :key="i">
				<view class="left-num">
					<view>{{item.memo}}</view>
					<view class="time">{{item.createtime}}</view>
				</view>
				<view class="right-num" :style="item.score>0?'':'color:#FF4530'">
					{{item.score}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return{
				is_incomeId:'',
				index:0,
				integralList:[]
			}
		},
		onLoad() {
			this.integral()
		},
		watch:{
			index(val){
				if(val== 1){
					this.is_incomeId = 1
				}else if(val == 2){
					this.is_incomeId = 0
				}else{
					this.is_incomeId = ''
				}
				this.integral()
			}
		},
		methods:{
			integral(){
				this.$api.get({
					url:'/jmy/user/scoreLog',
					data:{
						is_income: this.is_incomeId
					},
					success:res=>{
						this.integralList = res.data
						console.log(this.integralList)
					}
				})
			}
		}
	}
</script>

<style>
	.left-num {
		font-family: Source Han Sans;
		font-size: 14px;
		font-weight: 550;
		letter-spacing: 0em;
		color: #656565;
		width: 70%;


	}

	.time {
		font-family: Source Han Sans;
		font-size: 12px;
		font-weight: normal;
		line-height: normal;
		letter-spacing: 0em;
		line-height: 1;
		font-feature-settings: "kern" on;
		color: #999999;
	}

	.right-num {
		font-family: Source Han Sans;
		font-size: 20px;
		font-weight: normal;
		line-height: normal;
		letter-spacing: 0em;
		color: #00C10A;
		line-height: 4;
		text-align: right;
		width: 30%;
	}

	.num {
		height: 69px;
		border-bottom: 1px solid #F5F5F5;
		display: flex;
		justify-content: space-between;
	}

	.count {
		background: #FFF;
		width: 100%;
		height: auto;
		padding: 10px 40px 0 40px;
		line-height: 3;
	}

	.integral {
		display: flex;
		justify-content: center;
		align-items: center;
		width: 100%;
		background: #FFF;
		height: 42px;
	}

	.btn-x {
		height: 100%;
		width: 60px;
		margin-left: 40px;
		border-bottom: 2px solid #FF4530;
	}

	.xian {
		border-bottom: 1px solid #F0F0F0;
		text-align: center;
		width: 33%;
		height: 100%;
		line-height: 3;
	}
</style>